<template>
	<view>
		<view class="addressIn">
			<view class="addressCont" v-for="(item, index) in list" :key="index">
				<view v-if="item.address">
					<view class="addressFont">
						{{item.name}}
					</view>
					<view class="pageList">
						<view class="pagesTop">
							<view class="text">
								{{item.address}}
							</view>
							<view class="pagesImgs" @tap="copy(item.address)">
								<u--image src="/static/img/copyImg.png" width="70rpx" height="70rpx">
								</u--image>
							</view>
						</view>
						<view class="pagesTips" v-if="item.tips">
							{{item.tips}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	import {
		blockchainAddress
	} from '@/api/user.js'
	export default {
		data() {
			return {
				list: []
			}
		},
		computed: {},
		onLoad() {
			this.onGetAddress();
		},
		onReady() {},
		methods: {
			async onGetAddress() {
				try {
					const res = await blockchainAddress()
					this.list = res.data
				} catch (e) {
					uni.showToast({
						title: e.data || e.message,
						icon: 'none'
					})
				}
			},
			copy(address) {
				let _this = this
				uni.setClipboardData({
					data: address,
					showToast: false,
					success: function() {
						_this.$refs.uToast.show({
							message: "复制成功~"
						});

					},
					fail: function() {
						_this.$refs.uToast.show({
							message: "复制失败~"
						});
					}
				})
			}
		},
	}
</script>
<style>
	page {
		background: #f4f4f4 !important;
	}
</style>
<style lang="scss">
	.addressIn {
		margin: 0rpx 40rpx 0rpx;
	}

	.addressCont {
		margin: 60rpx 0 0;

		.addressFont {
			font-size: 28rpx;
			color: #000000;
			margin-bottom: 30rpx;
		}

		.pageList {
			background: #ffffff;
			border-radius: 10rpx;
			padding: 40rpx 30rpx 28rpx;

			.pagesTop {
				padding-bottom: 36rpx;
				margin-bottom: 29rpx;
				border-bottom: 2rpx solid #fafafb;
				display: flex;
				justify-content: space-between;

				.text {
					color: #000;
					font-size: 28rpx;
					word-wrap: break-word;
					width: 80%;
					word-wrap: break-word;
				}
			}

			.pagesTips {
				font-size: 22rpx;
				color: #bcbcbc;
			}
		}
	}
</style>
